namespace Microsoft.ServiceModel.Samples.Discovery.Protocol
{
    using System;
    using System.Xml;
    using System.Xml.Serialization;
    using System.ServiceModel;
    
    [ServiceContract(Namespace=ProtocolStrings.Namespace,
        CallbackContract = typeof(IFindResponseContract))]
    [XmlSerializerFormat]
    public interface IFindContract
    {
        [OperationContract(Action = ProtocolStrings.ProbeAction, IsOneWay = true)]
        void ProbeOperation(ProbeMessage request);

        [OperationContract(Action = ProtocolStrings.ResolveAction, IsOneWay = true)]
        void ResolveOperation(ResolveMessage request);
    }

    [ServiceContract(Namespace = ProtocolStrings.Namespace)]
    [XmlSerializerFormat]
    public interface IFindResponseContract
    {
        [OperationContract(Action = ProtocolStrings.ProbeMatchesAction, IsOneWay = true)]
        void ProbeMatchOperation(ProbeMatchesMessage response);

        [OperationContract(Action = ProtocolStrings.ResolveMatchesAction, IsOneWay = true)]
        void ResolveMatchOperation(ResolveMatchesMessage response);

        [OperationContract(Action = ProtocolStrings.HelloAction, IsOneWay = true)]
        void HelloOperation(HelloMessage message);
    }

    [MessageContract(IsWrapped=false)]
    public class ProbeMessage
    {
        Probe probe;

        public ProbeMessage()
            : this(null)
        {
        }

        public ProbeMessage(Probe probe)
        {
            this.probe = probe;
        }

        [MessageBodyMember(Name = ProtocolStrings.ProbeElement,
            Namespace = ProtocolStrings.Namespace)]
        public Probe Probe
        {
            get
            {
                return this.probe;
            }

            set
            {
                this.probe = value;
            }
        }
    }

    [MessageContract(IsWrapped=false)]
    public class ResolveMessage
    {
        Resolve resolve;

        public ResolveMessage()
            : this(null)
        {
        }

        public ResolveMessage(Resolve resolve)
        {
            this.resolve = resolve;
        }

        [MessageBodyMember(Name = ProtocolStrings.ResolveElement,
            Namespace = ProtocolStrings.Namespace)]
        public Resolve Resolve
        {
            get
            {
                return this.resolve;
            }

            set
            {
                this.resolve = value;
            }
        }
    }

    [MessageContract(IsWrapped=false)]
    public class ProbeMatchesMessage
    {
        ProbeMatches probeMatches;

        public ProbeMatchesMessage()
            : this(null)
        {
        }

        public ProbeMatchesMessage(ProbeMatches probeMatches)
        {
            this.probeMatches = probeMatches;
        }

        [MessageBodyMember(Name = ProtocolStrings.ProbeMatchesElement,
            Namespace = ProtocolStrings.Namespace)]
        public ProbeMatches ProbeMatches
        {
            get
            {
                return this.probeMatches;
            }

            set
            {
                this.probeMatches = value;
            }
        }
    }

    [MessageContract(IsWrapped=false)]
    public class ResolveMatchesMessage
    {
        ResolveMatches resolveMatches;

        public ResolveMatchesMessage()
            : this(null)
        {
        }

        public ResolveMatchesMessage(ResolveMatches resolveMatches)
        {
            this.resolveMatches = resolveMatches;
        }

        [MessageBodyMember(Name = ProtocolStrings.ResolveMatchesElement,
            Namespace = ProtocolStrings.Namespace)]
        public ResolveMatches ResolveMatches
        {
            get
            {
                return this.resolveMatches;
            }

            set
            {
                this.resolveMatches = value;
            }
        }
    }
}
